﻿Public Class FormSettings
#Region "Load & Save Settings"
    Private Sub FormSettings_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        '' load all the application settins to the components
        '' that are part of this form
        chkArtist.Checked = My.Settings.ShowArtist
        chkDuration.Checked = My.Settings.ShowDuration
        chkRandom.Checked = My.Settings.PlayerRandom
        chkRepeat.Checked = My.Settings.PlayerLoop
        chkTitle.Checked = My.Settings.ShowTitle
        chkTopMost.Checked = My.Settings.Topmost
        cboClient.SelectedIndex = My.Settings.PlayerClient
        cboDisplay.SelectedIndex = My.Settings.WindowerDisplay
        txtX.Text = My.Settings.WindowerX
        txtY.Text = My.Settings.WindowerY
        cbosep.SelectedIndex = My.Settings.WinampSplit
        cboSize.SelectedIndex = My.Settings.FontSize - 8
        BackColorz.SelectedColor = My.Settings.Backcolor
        FontColorz.SelectedColor = My.Settings.FontColor
        chkBold.Checked = My.Settings.FontBold
        If FormMain.TopMost = True Then Me.TopMost = True

    End Sub

    Private Sub btnOK_Click(sender As System.Object, e As System.EventArgs) Handles btnOK.Click
        FormMain.TopMost = chkTopMost.Checked
        My.Settings.ShowArtist = chkArtist.Checked
        My.Settings.ShowDuration = chkDuration.Checked
        My.Settings.PlayerRandom = chkRandom.Checked
        My.Settings.PlayerLoop = chkRepeat.Checked
        My.Settings.ShowTitle = chkTitle.Checked
        My.Settings.Topmost = chkTopMost.Checked
        My.Settings.PlayerClient = cboClient.SelectedIndex
        My.Settings.WindowerDisplay = cboDisplay.SelectedIndex
        My.Settings.WindowerX = txtX.Text
        My.Settings.WindowerY = txtY.Text
        My.Settings.WinampSplit = cbosep.SelectedIndex

        My.Settings.FontSize = cboSize.SelectedIndex + 8
        My.Settings.FontColor = FontColorz.SelectedColor
        My.Settings.Backcolor = BackColorz.SelectedColor
        My.Settings.FontBold = chkBold.Checked
        My.Settings.Save()


        If My.Settings.PlayerClient = 0 Then
            If PClient = 1 Then
                WinampPlayerControl("stop", "")
            ElseIf PClient = 2 Then
                iTunesPlayerControl("stop", "")
            End If
            If STrack.PlayStateInt = 3 Then
                SControlSettingsPlay()
            Else
                SControlSettings()
                If My.Settings.WindowerDisplay = 0 Then
                    DisplayTrack("FFXI Media Player: Standalone Client")
                Else
                    DisplayTrack("FFXI Media Player" + vbNewLine + "Standalone Client")
                End If
            End If

        ElseIf My.Settings.PlayerClient = 1 Then
            If PClient = 0 Then
                StandalonePlayerControl("stop", "")
            ElseIf PClient = 2 Then
                iTunesPlayerControl("stop", "")
            End If
            WControlSettings()
            If My.Settings.WindowerDisplay = 0 Then
                DisplayTrack("FFXIMP: Winamp Client")
            Else
                DisplayTrack("FFXIMP Winamp" + vbNewLine + "Winamp Client")
            End If
        ElseIf My.Settings.PlayerClient = 2 Then
            If PClient = 0 Then
                StandalonePlayerControl("stop", "")
            ElseIf PClient = 1 Then
                WinampPlayerControl("stop", "")
            End If
            IControlSettings()
            If My.Settings.WindowerDisplay = 0 Then
                DisplayTrack("FFXI Media Player: iTunes Client")
            Else
                DisplayTrack("FFXI Media Player" + vbNewLine + "iTunes Client")
            End If
        End If
        FormMain.TopMost = My.Settings.Topmost
        PClient = My.Settings.PlayerClient


    End Sub
#End Region

    Private Sub btnCancel_Click(sender As System.Object, e As System.EventArgs) Handles btnCancel.Click
        Me.Close()
    End Sub

    Private Sub FontColorz_SelectedColorChanged(SelectedColor As System.Drawing.Color) Handles FontColorz.SelectedColorChanged
        lblSample.ForeColor = FontColorz.SelectedColor
    End Sub

    Private Sub BackColorz_SelectedColorChanged(SelectedColor As System.Drawing.Color) Handles BackColorz.SelectedColorChanged
        lblSample.BackColor = BackColorz.SelectedColor
    End Sub

End Class